package com.fpt.mockproject.j21.absd.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.NaturalId;

@Entity
@Table(name = "ORGANISATION")
@DynamicUpdate(value = true)
public class Organisation {
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@Column(name = "OrgID", nullable = false, updatable = false, unique = true)
	private Long orgID;
	
	@NaturalId
	@Column(name = "OrgName", nullable = false, unique = true)
	private String orgName;
	
	@Column(name = "PreferredOrg")
	private Boolean preferredOrg;
	
	@Column(name = "ExpressOfInter")
	private Boolean expressOfInter;
	
	@Column(name = "Active")
	private Boolean active;
	
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinColumn(name = "AddressID")
	private Address address;
	
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "organisation")
	private Set<Directorate> directorates = new HashSet<>(0);
	
	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL, mappedBy = "organisation")
	private Set<SupportingMaterial> supportingMaterials = new HashSet<>(0);
	
	@ManyToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	@JoinTable(name = "REFERENCE_DATA_ORGANISATION", 
		joinColumns = {
			@JoinColumn(name = "OrgID")},
		inverseJoinColumns = {
			@JoinColumn(name = "RefID")})
	private Set<ReferenceData> referDatas = new HashSet<>(0);
	
	public Set<SupportingMaterial> getSupportingMaterials() {
		return supportingMaterials;
	}
	public void setSupportingMaterials(Set<SupportingMaterial> supportingMaterials) {
		this.supportingMaterials = supportingMaterials;
	}
	public Set<Directorate> getDirectorates() {
		return directorates;
	}
	public void setDirectorates(Set<Directorate> directorates) {
		this.directorates = directorates;
	}
	public Set<ReferenceData> getReferDatas() {
		return referDatas;
	}
	public void setReferDatas(Set<ReferenceData> referDatas) {
		this.referDatas = referDatas;
	}
	public Address getAddress() {
		return address;
	}
	public void setAddress(Address address) {
		this.address = address;
	}
	public Long getOrgID() {
		return orgID;
	}
	public void setOrgID(Long orgID) {
		this.orgID = orgID;
	}
	public String getOrgName() {
		return orgName;
	}
	public void setOrgName(String orgName) {
		this.orgName = orgName;
	}
	public Boolean getPreferredOrg() {
		return preferredOrg;
	}
	public void setPreferredOrg(Boolean preferredOrg) {
		this.preferredOrg = preferredOrg;
	}
	public Boolean getExpressOfInter() {
		return expressOfInter;
	}
	public void setExpressOfInter(Boolean expressOfInter) {
		this.expressOfInter = expressOfInter;
	}
	public Boolean getActive() {
		return active;
	}
	public void setActive(Boolean active) {
		this.active = active;
	}
}
